<?php 
namespace Api\Controller;
class ApiController extends CommonController{
	
	protected $sms;
	protected $apiService;

	
	function _initialize() {
		parent::_initialize();
		$this->sms = D('Sms');
		$this->apiService = D('Api','Service');
	}

	
	//发送短信
	public function sendsms(){
		$mobile = I('mobile');
		$code = rand(100000,999999);
		$type = I('type');
		if($this->apiService->_send_sms($mobile,$code,$type)){
			$this->success('发送成功');
		}else{
			$this->error('发送失败');
		}
	}
	
	//判断验证码对错
	public function marrysms(){
		$mobile = I('mobile');
		$code = I('code');
		$type = I('type');
		if($this->sms->where(array('mobile'=>$mobile,'code'=>$code,'type'=>$type,'token_time'=>array('gt',time())))->find()){
			$this->success('验证码正确');
		}else{
			$this->error('验证码错误');
		}
	}
}